<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>编辑用户</title>
  </head>
  <body>
    <script type="text/javascript">
      Ext.onReady(function(){
        var userName = new Ext.form.TextField({
          fieldLabel: '用户ID',
          allowBlank: false,
          name: 'name',
          anchor: '90%',
          value: '<%=@user.name%>'
        });

        var userPassword = new Ext.form.TextField({
          fieldLabel: '用户密码',
          allowBlank: false,
          name: 'password',
          anchor: '90%',
          value: '<%=@user.password%>'
        });

        var userId = new Ext.form.Hidden({
          name: 'user_id',
          value: '<%=@user.id%>'
        });
        
        //提交按钮
        var editUserButton = new Ext.Button({
          text: '提交',
          iconCls: 'icon-save',
          handler: function(){
            editUserButton.setDisabled(true);
            if (editUserFormPanel.form.isValid()) {
              editUserFormPanel.form.submit({
                success: function(result, resp){
                  if (resp.result.info.indexOf("成功") >= 0) {
                    editUserWin.destroy();
                    userDS.reload();
                  } else {
                    Ext.MessageBox.alert('消息', resp.result.info);
                    editUserButton.enable();
                  }
                },
                failure: function(result, request){
                  editUserButton.enable();
                  Ext.MessageBox.alert('消息', '服务器的通信失败!');
                }
              });
            }
            else {
              editUserButton.enable();
              //Ext.MessageBox.alert('输入验证有错', '请输入必输选项');
            }
          }
        })
        
        var editUserFormPanel = new Ext.form.FormPanel({
          labelWidth: 65,
          width: '200',
          labelAlign: 'right',
          frame : true,
          url: '/user/updateUser',
          items: [userName,userPassword,userId],
          buttons: [editUserButton,{
              text: '关闭',
              iconCls: 'exit',
              handler: function(){
                editUserWin.destroy();
              }
            }]
        });
        editUserFormPanel.render('new_user_form');
      })
    </script>
    <div id="new_user_form"></div>
  </body>
</html>
